1. Consider the following class:public class IdentifyMyParts { public static int x = 7; public int y = 3; }a. What are the class variables?b. What are the instance variables?
c. What is the output from the following code:
IdentifyMyParts a = new IdentifyMyParts(); IdentifyMyParts b = new IdentifyMyParts(); a.y = 5; b.y = 6; a.x = 1; b.x = 2; System.out.println("a.y = " + a.y); System.out.println("b.y = " + b.y); System.out.println("a.x = " + a.x); System.out.println("b.x = " + b.x); System.out.println("IdentifyMyParts.x = " + IdentifyMyParts.x);
1. Write a class whose instances represent a single playing card from a deck of cards. Playing cards have two distinguishing properties: rank and suit. Be sure to keep your solution as you will be asked to rewrite it in Enum Types.2. Write a class whose instances represent a full deck of cards. You should also keep this solution.
Hint: You can use theassertstatement to check your assignments. You write:If the boolean expression is false, you will get an error message. For example,assert (boolean expression to test);should returnassert toString(ACE) == "Ace";true, so there will be no error message.If you use the
assertstatement, you must run your program with theeaflag:java -ea YourProgram.class
3. Write a small program to test your deck and card classes. The program can be as simple as creating a deck of cards and displaying its cards.
ATENCIÓN: La traducción de esta documentación es un esfuerzo personal y voluntario. NO es un documento oficial del propietario de la tecnología Java, Oracle, ni está patrocinado por esta empresa.
Los documentos originales y actualizados (en inglés) están disponibles en: http://docs.oracle.com/javase/tutorial/. La versión disponible en este sitio es la publicada en Marzo de 2008 (más información en: "What's new and What's Old? The History of the Tutorial").
Dirige cualquier comentario, petición, felicitación, etc. a tutorialesjava@codexion.com.
Si quieres ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesitas que se traduzca algún capítulo en concreto puedes invitarme a un café: